import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)
let initState = {
  // token的信息对象
  tokenInfo: {}
}

const stateStr = localStorage.getItem('state')

if (stateStr) {
  initState = JSON.parse(stateStr)
}

export default new Vuex.Store({
  // state: {
  //   // 用来存储token信息的对象，将来这个对象中会包含两个属性 {token, refresh_token}
  //   tokenInfo: {}
  // },
  state: initState,
  mutations: {
    updateTokenInfo(state, payload) {
      state.tokenInfo = payload
      console.log(state)
    }
  },
  actions: {

  }
})
